#ifndef __KSVGEDITOR_UI_KDRAWMODESTRATEGY_H_
#define __KSVGEDITOR_UI_KDRAWMODESTRATEGY_H_


#include <QGraphicsItem>
#include "kinteractionmodestrategy.h"

class KExportShape;

class KDrawModeStrategy:public KInteractionModeStrategy
{
public:
	explicit KDrawModeStrategy();
	~KDrawModeStrategy() override;

	void handleMousePress(const QPointF& scenePos, QMouseEvent* event) override;
	void handleMouseMove(const QPointF& scenePos, QMouseEvent* event) override;
	void handleMouseRelease(const QPointF& scenePos, QMouseEvent* event) override;
	void handleWheelEvent(QWheelEvent* event) override{};

private:
	QPointF clampToCanvas(const QPointF& prev, const QPointF& next, const QRectF& canvas);
	void assignTopZValue(QGraphicsItem* item, QGraphicsScene* scene);
	bool handleMultiClickShape(KShapeType type, const QPointF& scenePos);
	void createTextShapeAt(const QPointF& scenePos);
	bool isPointTooClose(const QPointF& p1, const QPointF& p2, qreal threshold);

private:
	KExportShape* m_pNewShape = nullptr;
	int m_pointCount = 0;
	bool m_waitingMultiClick = false;
	QVector<QPointF> m_multiPoints;
};
#endif //__KSVGEDITOR_UI_KDRAWMODESTRATEGY_H_